import com.fz.Mapper.adminMapper;
import com.fz.entity.admin;
import com.fz.entity.adminInfo;
import org.apache.ibatis.io.Resources;
import org.apache.ibatis.session.SqlSession;
import org.apache.ibatis.session.SqlSessionFactory;
import org.apache.ibatis.session.SqlSessionFactoryBuilder;
import org.junit.After;
import org.junit.Before;
import org.junit.Test;

import javax.sound.midi.Soundbank;
import java.io.IOException;
import java.io.InputStream;
import java.util.List;

/**
 * Created by xiao zeng on 2017/6/21.
 */
public class adminDome {
    protected SqlSessionFactory sf;
    protected SqlSession session;

    @Before
    public void inio() throws IOException {
        String resoures="mybatis-conf.xml";
        InputStream inputStream = Resources.getResourceAsStream(resoures);
        this.sf = new SqlSessionFactoryBuilder().build(inputStream);
        this.session = sf.openSession();

    }
    @After
    public void close(){
        session.commit();
        session.close();
    }
    @Test
    public void show(){
        adminMapper  sdao = session.getMapper(adminMapper.class);
        admin list = sdao.query(2);
        System.out.println(list.getName());
        List<adminInfo> la = list.getAdminInfos();
        for (adminInfo ai : la ){
            System.out.println(ai);
        }
//        for(admin a :list){
//            List<adminInfo> b = a.getAdminInfos();
//            for(adminInfo c : b){
//                System.out.println(c.getName());
//            }
//        }

    }

}
